package com.woniu.user.mapper;

import com.woniu.user.pojo.UserLikeCar;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 用户关注车辆表 Mapper 接口
 * </p>
 *
 * @author LiFangyu
 * @since 2023-02-15
 */
public interface UserLikeCarMapper extends BaseMapper<UserLikeCar> {

    @Select("select * from t_user_like_car where user_id = #{id} and car_id = #{carId}")
    UserLikeCar selectIsLikeCar(@Param("id") String id, @Param("carId")String carId);

    @Update("UPDATE t_user_like_car SET is_deleted = 0 WHERE user_id = #{id} and car_id = #{carId} AND is_deleted = 1")
    int updateIsDeleted(@Param("id") String id, @Param("carId")String carId);

    @Update("UPDATE t_user_like_car SET is_deleted = 1 WHERE user_id = #{id} and car_id = #{carId} AND is_deleted = 0")
    int rmLikeCar(@Param("id") String id, @Param("carId")String carId);
}
